XTemplate
public class XTemplate
Field Summary | |
---|---|
protected array Blocks | |
protected static string Cache directory path | |
protected static bool Enables disk caching of precompiled templates | |
protected static array Stores debug data | |
protected static boolean Enables debug dumping | |
protected static boolean Prints debug mode screen | |
protected array Blocks already displayed (for debug mode) | |
string Template file name | |
private bool Indicates that root-level blocks were found during another run | |
protected array Index for quick block search. | Maps block paths to actual array indices. |
protected array | Contains a list of names of all tags present in the template |
array Assigned template vars |
Constructor Summary | |
---|---|
void | __construct(string path) Simplified constructor |
Method Summary | |
---|---|
string | TPL code representation of the entire CoTemplate object for debugging |
XTemplate | assign(mixed name, mixed val, string prefix) Assigns a template variable or an array of them |
static array | Returns debug data dumped by CoTemplate if debug option is on. |
static string | debugVar(string name, mixed value) Debugging output of a tag name and current value |
mixed | get(string name) Returns current template variable value |
array | getTags() Returns the list of names of all tags present in the template |
boolean | hasBlock(string name) Returns TRUE if the block is present in template or FALSE otherwise |
boolean | hasTag(string name) Returns TRUE if the tag is present in template or FALSE otherwise |
static void | init(array options) Initializes static class configuration. |
private static string | restart_include_files(array m) restart() replace callback for FILE inclusion |
private string | restart_root_blocks(array m) restart() replace callback for root-level blocks |
XTemplate | restart(string path) Loads template file structure into memory |
XTemplate | compile(string code) Compiles the template from raw TPL code. |
private static string | substitute_var(array m) PCRE callback which immediately subsitutes a TPL var with its value |
XTemplate | out(string block) Prints a parsed block |
XTemplate | parse(string block) Parses a block |
XTemplate | reset(string block) Clears a parset block data |
string | text(string block) Returns parsed block HTML |
protected array Blocks $blocks = array()
protected static string Cache directory path $cache_dir = ''
protected static bool Enables disk caching of precompiled templates $cache_enabled = false
protected static array Stores debug data $debug_data = array()
protected static boolean Enables debug dumping $debug_mode = false
protected static boolean Prints debug mode screen $debug_output = false
protected array Blocks already displayed (for debug mode) $displayed_blocks = array()
public string Template file name $filename = ''
private bool Indicates that root-level blocks were found during another run $found = false
protected array Index for quick block search. $index = array()
protected array $tags = null
public array Assigned template vars $vars = array()
public void __construct(string path)
public string __toString()
public XTemplate assign(mixed name, mixed val, string prefix)
public static array debugData()
array(
'filename.tpl' => array(
'BLOCK.NAME' => array(
'TAG_NAME' => 'tag value',
// ...
),
// ...
),
// ...
);
public static string debugVar(string name, mixed value)
public mixed get(string name)
public array getTags()
public boolean hasBlock(string name)
public boolean hasTag(string name)
public static void init(array options)
$options = array(
'cache' => false,
'cache_dir' => '',
'cleanup' => false,
'debug' => false,
'debug_output' => false,
);
private static string restart_include_files(array m)
private string restart_root_blocks(array m)
public XTemplate restart(string path)
public XTemplate compile(string code)
$raw_tpl = file_get_contents('some/file.tpl');
// Process $raw_tpl code here
$t = new XTemplate();
$t->compile($raw_tpl);
// Use $t as normal XTemplate object
private static string substitute_var(array m)
public XTemplate out(string block)
public XTemplate parse(string block)
public XTemplate reset(string block)
public string text(string block)